home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Into His Marvelous Light
/
Into His Marvelous LIGHT.iso
/
ending.dxr
/
00178_Script_Loop for X Seconds
< prev
next >
Wrap
Text File
|
2001-09-06
|
8KB
|
274 lines
-- DESCRIPTION --
on getBehaviorDescription me
return "¼
LOOP FOR X SECONDS: FRAME BEHAVIOR"&RETURN&RETURN&"¼
This behavior will make the playback head loop for a fixed length of time over ¼
a certain number of frames, then jump to a chosen marker. You can choose ¼
whether the playback head jumps immediately at the end of the period, or ¼
whether it should run right through to the last frame of the span."&¼
RETURN&RETURN&"¼
Drag this behavior to the frame channel of the Score Window, then stretch it ¼
out over the frames you wish to loop over. If you wish to remain on the same ¼
frame, then simply do not stretch out the sprite."&RETURN&RETURN&"¼
PERMITTED MEMBER TYPES:"&RETURN&"Frame behavior"&RETURN&RETURN&"¼
PARAMETERS:"&RETURN&"¼
* Duration of loop (1 tick - 120 hours)"&RETURN&"¼
* Marker to jump to at the end of the period"&RETURN&"¼
* Playback head jumps immediately | at the end of the cycle"
end getBehaviorDescription
on getBehaviorTooltip me
return "¼
Frame behavior."&RETURN&"¼
Stretch this behavior over a sequence"&RETURN&"¼
of frames to make the playback head"&RETURN&"¼
loop for a fixed length of time then"&RETURN&"¼
jump to a chosen marker."&RETURN&RETURN&"¼
Option: ensure that the cycle is fully"&RETURN&"¼
completed before the playback head jumps."
end getBehaviorTooltip
-- NOTES FOR DEVELOPERS --
-- Most Frame behaviors are intended to be triggered immediately. This one
-- is designed to be stretched over a number of frames, to act like a loop.
-- The playback head will run the whole span of the sprite, then return to
-- the frame it entered on.
--
-- Sprites in Director 7 can know where they begin and end, through the
-- startFrame and endFrame properties. This behavior exploits these to
-- loop back to frame mySprite.startFrame when the playback head triggers
-- the exitFrame handler in frame mySprite.endFrame
-- HISTORY --
-- 3 November 1998: written for the D7 Behaviors Palette by James Newton
-- 19 November 1998: now handles #previous | #loop | #next
-- PROPERTIES --
-- author-defined parameters
property myTimeOut
property myTimeUnit
property myTimeOutFrame
property myImmediateJump
-- internal properties
property myStartFrame
property myStartTicks
property myEndFrame
-- EVENT HANDLERS --
on beginSprite me
Initialize me
end beginSprite
on exitFrame me
CheckTimeOut me
end exitFrame
-- CUSTOM HANDLERS --
on Initialize me -- sent by beginSprite
thisSprite = sprite(the currentSpriteNum)
myStartFrame = thisSprite.startFrame
myEndFrame = thisSprite.endFrame
if symbolP (myTimeOutFrame) then
case (myTimeOutFrame) of
#previous: jumpToFrame = marker (-1)
#loop: jumpToFrame = marker (0)
#next: jumpToFrame = marker (1)
end case
else
jumpToFrame = marker (myTimeOutFrame)
end if
-- Error checking
if the currentSpriteNum then
ErrorAlert (me, #invalidChannel, the currentSpriteNum)
end if
if not jumpToFrame then
jumpToFrame = myEndFrame + 1
ErrorAlert (me, #missingMarker, jumpToFrame)
else if jumpToFrame >= myStartFrame and jumpToFrame <= myEndFrame then
jumpToFrame = myEndFrame + 1
ErrorAlert (me, #endlessLoop, jumpToFrame)
end if
-- End of error checking
myStartTicks = the ticks
-- Convert properties
case myTimeUnit of
#seconds: myTimeOut = myTimeOut * 60
#minutes: myTimeOut = myTimeOut * 60 * 60
#hours: myTimeOut = myTimeOut * 60 * 60 * 60
end case
myTimeOut = myTimeOut + myStartTicks
myTimeOutFrame = jumpToFrame
myImmediateJump = (myImmediateJump = "jump immediately")
end Initialize
on CheckTimeOut me -- sent by exitFrame
if the ticks > myTimeOut then
if myImmediateJump or (the frame = myEndFrame) then
go myTimeOutFrame
end if
else if (the frame = myEndFrame) then
go myStartFrame
end if
end CheckTimeOut
-- ERROR CHECKING --
-- ERROR CHECKING --
on ErrorAlert me, theError, data
-- sent by getPropertyDescriptionList, Initialize
case theError of
#getPDLError:
alert "¼
Error: This behavior should dropped on the Stage or into the Behavior Channel ¼
of the Score."&RETURN&RETURN&"¼
Hit OK and then delete this behavior from the sprite."&RETURN&RETURN&"¼
For more information on deleting Behaviors, see the Help system."
if the optionDown then
return ¼
[ ¼
#getPDLError: ¼
[ ¼
#comment: "ERROR: Frame Behavior. Click 'Cancel'.", ¼
#format: #string, ¼
#range: [""], ¼
#default: "" ¼
] ¼
]
end if
otherwise
-- Determine the behavior's name
behaviorName = string (me)
delete word 1 of behaviorName
delete the last word of behaviorName
delete the last word of behaviorName
case theError of
#invalidChannel:
if the runMode = "Author" then
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
Behavior "&behaviorName&"should be attached to the frame script channel."&¼
RETURN&RETURN&"Current channel = "&data
abort
end if
#missingMarker:
if the runMode = "Author" then
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
Frame behavior "&behaviorName&"is set to jump to marker '"&myTimeOutFrame&"'. ¼
This marker cannot be found. Choose a valid marker in the Behavior Parameters ¼
dialog."&RETURN&RETURN&"¼
In the meantime, frame "&data&" will be used instead."
end if
#endlessLoop:
if the runMode = "Author" then
if symbolP (myTimeOutFrame) then
case (myTimeOutFrame) of
#previous: jumpToFrame = marker (-1)
#loop: jumpToFrame = marker (0)
#next: jumpToFrame = marker (1)
end case
else
jumpToFrame = marker (myTimeOutFrame)
end if
alert "¼
BEHAVIOR ERROR: Frame "&the frame&", Sprite "&me.spriteNum&RETURN&RETURN&"¼
Frame behavior "&behaviorName&"is set to jump to marker '"&myTimeOutFrame&"' ¼
(frame "&jumpToFrame&"). This is within the span of the behavior and will ¼
cause an endless loop."&RETURN&RETURN&"¼
Frame "&data&" will be used instead."
end if
end case
end case
end ErrorAlert
-- AUTHOR-DEFINED PARAMETERS --
on getPropertyDescriptionList me
if the currentSpriteNum then
return ErrorAlert (me, #getPDLError)
end if
nextMarker = NextMarker (me)
return ¼
[ ¼
#myTimeOut: ¼
[ ¼
#comment: "Loop over selected frames for...", ¼
#format: #integer, ¼
#range: [#min: 1, #max: 120], ¼
#default: 30 ¼
], ¼
#myTimeUnit: ¼
[ ¼
#comment: "", ¼
#format: #symbol, ¼
#range: [#ticks, #seconds, #minutes, #hours], ¼
#default: #seconds ¼
], ¼
#myTimeOutFrame: ¼
[ ¼
#comment: "... then jump to marker:", ¼
#format: #marker, ¼
#default: nextMarker ¼
], ¼
#myImmediateJump: ¼
[ ¼
#comment: "When the time is up:", ¼
#format: #string, ¼
#range: ["complete the loop", "jump immediately"], ¼
#default: "jump immediately" ¼
] ¼
]
end getPropertyDescriptionList
on NextMarker me -- sent by getPropertyDescriptionList
labelString = the labelList
delete the last char of labelString
markerCount = the number of lines of labelString
theFrame = the frame
repeat with i = 1 to markerCount
theMarker = line i of labelString
markerFrame = marker (theMarker)
if theFrame < markerFrame then
return theMarker
end if
end repeat
end NextMarker